<?php
if (! defined ( 'BASEPATH' ))
	exit ( 'No direct script access allowed' );
class System_model extends MY_Model {
	var $table = 'system';
	
	// 构造函数
	public function __construct() {
		parent::__construct ();
	}
	
	/**
	 * 查找详细信息
	 *
	 * @param integer $id        	
	 * @return array
	 */
	public function findSystemInfo() {
		$config = $this->get_result(NULL, array('field'=>'parent', 'order_by'=>'asc'));
		$data = array('title'=>array(), 'content'=>array());
		if(!empty($config)) {
			foreach ($config as $v) {
				if(!$v['parent']) {
					$data['title'][$v['id']] = $v['name'];
				} else {
					$data['content'][$v['parent']][] = $v;
				}
			}
		}
		return $data;
	}

	/**
	 * 更新信息
	 *
	 * @param array $data
	 * @param integer $id
	 * @return integer
	 */
	public function upSystemInfo($data, $id) {
		$this->db->trans_start();
		$this->db->update_batch($this->table, $data, $id);
		$this->db->trans_complete();
		return $this->db->trans_status();
	}

}
